import request from '@/utils/request';

enum API {
    //获取某一个三级分类已有SPU列表数据
    getSpuList="/admin/product/",
    //全部品牌接口
    allTradeMark="/admin/product/baseTrademark/getTrademarkList",
    //照片墙
    imgList="/admin/product/spuImageList/",
    //已有SPU:本身就拥有销售属性与属性值
    spuHasSaleAttr="/admin/product/spuSaleAttrList/",
    //全部SPU销售属性
    allSaleAttr="/admin/product/baseSaleAttrList",
    //修改已有的SPU
    updateSpu="/admin/product/updateSpuInfo",
    //添加一个新的SPU
    addSpu="/admin/product/saveSpuInfo",
    //获取平台属性的数据
    attrList="/admin/product/attrInfoList/",
    //添加SKU的接口
    addSku="/admin/product/saveSkuInfo",
    //获取SKU列表数据
    getSkuList = '/admin/product/findBySpuId/',
    //删除已有SPU
    removeSpu="/admin/product/deleteSpu/"
}

//获取某一个三级分类下全部的已有SPU的数据
export const reqGetSpuList = (page:number,limit:number,category3Id:string|number)=>request.get(API.getSpuList+`${page}/${limit}?category3Id=${category3Id}`);

//全部品牌的数据
export const reqAllTradeMark = ()=>request.get(API.allTradeMark);

//获取全部销售属性
export const reqAllSaleAttr = ()=>request.get(API.allSaleAttr);
//添加与修改SPU接口
export const reqAddOrUpdateSpu = (data:any)=>{
     if(data.id){
        return request.post(API.updateSpu,data); 
     }else{
         return request.post(API.addSpu,data);
     }
}

//获取平台属性的接口
export const reqAttrList = (category1Id:number|string,category2Id:number|string,category3Id:number|string)=>request.get(API.attrList+`${category1Id}/${category2Id}/${category3Id}`)
//照片墙的数据
export const reqImgList = (spuId:number)=>request.get(API.imgList+spuId);
//已有销售属性与属性值
export const reqSpuHasSaleAttr=(spuId:number)=>request.get(API.spuHasSaleAttr+spuId);

//添加SKU请求地址
export const reqAddSku = (data:any)=>request.post(API.addSku,data);

//获取某一个SPU下全部的sku
export const reqGetSkuList = (spuId:number)=>request.get(API.getSkuList+spuId);

//删除SPU
export const reqRemoveSpu = (spuId:number)=>request.delete(API.removeSpu+spuId)